package com.zhentao.filter;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;

@Configuration
@CrossOrigin(origins = "*")
public class GatewayRoutes {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("menu_route", r -> r.path("/menu/**")
                        .uri("http://localhost:7777"))
                .route("product_route", r -> r.path("/product/**")
                        .uri("http://localhost:7777"))
                .route("order_route", r -> r.path("/order/**")
                        .uri("http://localhost:7777"))
                .route("category_route", r -> r.path("/category/**")
                        .uri("http://localhost:7777"))
                .route("brand_route", r -> r.path("/brand/**")
                        .uri("http://localhost:7777"))
                .route("role_route", r -> r.path("/role/**")
                        .uri("http://localhost:7777"))
                .route("category_route", r -> r.path("/category/**")
                        .uri("http://localhost:7777"))
                .route("auth_route", r -> r.path("/auth/**")
                        .uri("http://localhost:8889"))
                .route("user_route", r -> r.path("/user/**")
                        .uri("http://localhost:8889"))
                .route("cart_route", r -> r.path("/cart/**")
                        .uri("http://localhost:8889"))
                .route("orders_route", r -> r.path("/orders/**")
                        .uri("http://localhost:8889"))
                .route("ShoppingCar_route", r -> r.path("/ShoppingCar/**")
                        .uri("http://localhost:8889"))
                .build();
    }

}    